﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace MinerManager.Forms
{
	public partial class FrmUpdate : DevExpress.XtraEditors.XtraForm
	{
		private int Second = 10;

		public FrmUpdate()
		{
			InitializeComponent();
		}

		private void FrmUpdate_Load(object sender, EventArgs e)
		{
			LabelStatus.Text = this.Second + "秒后自动更新";

			Action<object, EventArgs> onTick = delegate (object obj, EventArgs args)
			{
				if (this.Second <= 1)
				{
					this.DialogResult = DialogResult.OK;
					this.Close();
				}

				this.Second--;
				LabelStatus.Text = this.Second + "秒后自动更新";
			};

			System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer
			{
				Enabled = true,
				Interval = 1000
			};
			timer.Tick += new EventHandler(onTick);
			timer.Start();
		}

		private void BtnSave_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.OK;
		}

		private void BtnClose_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
		}
	}
}